/*
 * extends   jquery.1.10.2
 * name      head搜索模块，IE6导航左侧菜单。
 * author    liunwcj
 * email     1915681380@qq.com
 * example   URL引入，位置页面footer，HTML结构:首页头部搜索模块,
 * */
;(function ($) {
    var $J_sch_wrap = $('#J_sch_wrap');
    var $formTop = $('#formTop');
    var $keySearch = $("#keySearch");
    var $J_search = $('#J_search');
    var $schSel = $formTop.find('.sch-tip');

//sch-tip
    $schSel.hover(function () {
        $(this).addClass('sch-tip-hover');
        $schSel.find('li').on('click', function () {
            switch ($(this).text()) {
                case '试用品':
                    $formTop.attr({"action": domain_list});
                    $keySearch.attr("name", "keyword");
                    $J_search.attr({'name': 'topSearch', 'value': '1'});
                    break;
                case '众划算':
                    $formTop.attr({"action": domain_zhs_list + '/search/'});
                    $keySearch.attr("name", "key");
                    $J_search.attr({
                        'name': 'type',
                        'value': 'goods'
                    });
                    break;
                case '店铺':
                    $formTop.attr({"action": domain_list + "shop"});
                    $keySearch.attr("name", "key");
                    break;
            }
            $schSel.prepend($(this)).removeClass('sch-tip-hover');
            $(this).addClass('sel').siblings().removeClass('sel');
            $keySearch.focus();
        });
    }, function () {
        $(this).removeClass('sch-tip-hover');
    });

//search box  hover focus
    $J_sch_wrap.on('focusin', function () {
        $(this).addClass('search-wrap-focus');
    }).on('focusout', function () {
        if ($(this).hasClass('search-wrap-focus') && $schSel.hasClass('sch-tip-hover')) return;
        $(this).removeClass('search-wrap-focus');
    });

//顶部搜索验证
    $formTop.submit(function () {
        if ($.trim($keySearch.val()) == "") {
            alert("\u8bf7\u8f93\u5165\u641c\u7d22\u5173\u952e\u5b57");
            $keySearch.focus();
            return !1;
        }
    });

// 店铺搜索页面 Get关键字
    if($('#hidLogoinUid').length > 0){
        $keySearch.val(decodeURIComponent(sk.query('key')));
    }

//2014导航左侧菜单  Koala压缩"!-[1,]",头号去除
    if (!-[1, ] && !window.XMLHttpRequest) {
        $("#J_subNav").hover(function () {
            $(this).find(".sub-nav-bd").show();
            $(this).find(".arrow").addClass("arrow-hover");
        }, function () {
            $(this).find(".sub-nav-bd").hide();
            $(this).find(".arrow").removeClass("arrow-hover");
        });
    }
})(jQuery);